/* http://www.runoob.com/bootstrap/bootstrap-modal-plugin.html */

function parseId(id, userName) {
    $("#id").val(id);
    $("#myModalLabel").html("发送至用户：" + userName);
}

function sendCoin() {
    let sendCount = $.trim($("#sendCount").val());
    if (sendCount.length === 0) {
        $("#errorMsg").html("请输入发送数量！");
        return;
    }

    let rex = /^[1-9]*[1-9][0-9]*$/;
    if (!rex.test(sendCount)) {
        $("#errorMsg").html("请填写正整数！");
        return;
    }

    let form = $("#sendCoin");
    $.post(form.attr("action") + "sendCoin", form.serialize(), function (data) {
        data = eval('(' + data + ')');

        if (data.success) { $("#main-page").load(
            form.attr("action") + "list", {"page":$(".active span").text() - 1});
            $('#identifier').modal('hidden');
        }
        else { $("#errorMsg").html(data.message); }
    });
}